home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-9.10-netbook-remix-PL.iso / casper / filesystem.squashfs / usr / share / hplip / base / module.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2009-10-28  |  16KB  |  563 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import sys
  5. import re
  6. import getopt
  7. import os
  8. from g import *
  9. import tui
  10. import utils
  11. import device
  12. USAGE_FLAG_NONE = 0
  13. USAGE_FLAG_DEVICE_ARGS = 1
  14. USAGE_FLAG_SUPRESS_G_DEBUG_FLAG = 2
  15. USAGE_FLAG_FILE_ARGS = 4
  16.  
  17. class Module(object):
  18.     
  19.     def __init__(self, mod, title, version, doc, usage_data = None, avail_modes = None, supported_ui_toolkits = None, run_as_root_ok = False, quiet = False):
  20.         self.mod = mod
  21.         self.title = title
  22.         self.version = version
  23.         self.doc = doc
  24.         self.usage_data = usage_data
  25.         os.umask(31)
  26.         log.set_module(mod)
  27.         self.args = []
  28.         self.quiet = quiet
  29.         self.lock_file = None
  30.         prop.prog = sys.argv[0]
  31.         if os.getenv('HPLIP_DEBUG'):
  32.             log.set_level('debug')
  33.         
  34.         self.avail_modes = avail_modes
  35.         if supported_ui_toolkits is not None:
  36.             self.supported_ui_toolkits = supported_ui_toolkits
  37.             self.num_supported_ui_toolkits = len(self.supported_ui_toolkits)
  38.         else:
  39.             self.supported_ui_toolkits = []
  40.             self.num_supported_ui_toolkits = 0
  41.         self.default_ui_toolkit = sys_conf.get('configure', 'ui-toolkit', 'qt4')
  42.         self.num_installed_ui_toolkits = 0
  43.         self.installed_ui_toolkits = []
  44.         if utils.to_bool(sys_conf.get('configure', 'qt3', '0')):
  45.             self.installed_ui_toolkits.append(UI_TOOLKIT_QT3)
  46.             self.num_installed_ui_toolkits += 1
  47.         
  48.         if utils.to_bool(sys_conf.get('configure', 'qt4', '0')):
  49.             self.installed_ui_toolkits.append(UI_TOOLKIT_QT4)
  50.             self.num_installed_ui_toolkits += 1
  51.         
  52.         self.default_mode = INTERACTIVE_MODE
  53.         self.num_valid_modes = 0
  54.         if self.avail_modes is not None:
  55.             if GUI_MODE in self.avail_modes and prop.gui_build and self.installed_ui_toolkits:
  56.                 self.num_valid_modes += 1
  57.             
  58.             if INTERACTIVE_MODE in self.avail_modes:
  59.                 self.num_valid_modes += 1
  60.             
  61.             if NON_INTERACTIVE_MODE in self.avail_modes:
  62.                 self.num_valid_modes += 1
  63.             
  64.         
  65.         if self.avail_modes is not None:
  66.             if INTERACTIVE_MODE in self.avail_modes:
  67.                 self.default_mode = INTERACTIVE_MODE
  68.             elif NON_INTERACTIVE_MODE in self.avail_modes:
  69.                 self.default_mode = NON_INTERACTIVE_MODE
  70.             
  71.         
  72.         if self.supported_ui_toolkits is not None and prop.gui_build and self.installed_ui_toolkits:
  73.             if self.default_ui_toolkit == 'qt3' and UI_TOOLKIT_QT4 in self.supported_ui_toolkits and UI_TOOLKIT_QT3 not in self.supported_ui_toolkits and INTERACTIVE_MODE in self.avail_modes:
  74.                 self.default_mode = INTERACTIVE_MODE
  75.                 self.default_ui_toolkit = 'none'
  76.             elif (UI_TOOLKIT_QT4 in self.supported_ui_toolkits and self.default_ui_toolkit == 'qt4' or UI_TOOLKIT_QT4 in self.installed_ui_toolkits or UI_TOOLKIT_QT3 in self.supported_ui_toolkits) and self.default_ui_toolkit == 'qt3' and UI_TOOLKIT_QT3 in self.installed_ui_toolkits:
  77.                 self.default_mode = GUI_MODE
  78.             elif self.default_ui_toolkit == 'qt3' and UI_TOOLKIT_QT3 not in self.supported_ui_toolkits:
  79.                 if UI_TOOLKIT_QT4 in self.supported_ui_toolkits and UI_TOOLKIT_QT4 in self.installed_ui_toolkits:
  80.                     self.default_ui_toolkit = 'qt4'
  81.                     self.default_mode = GUI_MODE
  82.                 elif INTERACTIVE_MODE in self.avail_modes:
  83.                     self.default_mode = INTERACTIVE_MODE
  84.                 elif NON_INTERACTIVE_MODE in self.avail_modes:
  85.                     self.default_mode = NON_INTERACTIVE_MODE
  86.                 else:
  87.                     log.error('%s cannot be run using Qt3 toolkit.' % self.mod)
  88.                     sys.exit(1)
  89.             elif self.default_ui_toolkit == 'qt4' and UI_TOOLKIT_QT4 not in self.supported_ui_toolkits:
  90.                 if UI_TOOLKIT_QT3 in self.supported_ui_toolkits and UI_TOOLKIT_QT3 in self.installed_ui_toolkits:
  91.                     self.default_ui_toolkit = 'qt3'
  92.                     self.default_mode = GUI_MODE
  93.                 elif INTERACTIVE_MODE in self.avail_modes:
  94.                     self.default_mode = INTERACTIVE_MODE
  95.                 elif NON_INTERACTIVE_MODE in self.avail_modes:
  96.                     self.default_mode = NON_INTERACTIVE_MODE
  97.                 else:
  98.                     log.error('%s cannot be run using Qt4 toolkit.' % self.mod)
  99.                     sys.exit(1)
  100.             
  101.         
  102.         self.mode = self.default_mode
  103.         if os.getuid() == 0 and not run_as_root_ok:
  104.             log.warn('%s should not be run as root/superuser.' % mod)
  105.         
  106.  
  107.     
  108.     def setUsage(self, include_flags = 0, extra_options = None, extra_notes = None, see_also_list = None):
  109.         if self.doc:
  110.             self.usage_data = [
  111.                 (self.doc, '', 'name', True)]
  112.         else:
  113.             self.usage_data = []
  114.         summary = [
  115.             'Usage:',
  116.             self.mod]
  117.         content = []
  118.         notes = []
  119.         if include_flags & USAGE_FLAG_DEVICE_ARGS == USAGE_FLAG_DEVICE_ARGS:
  120.             summary.append('[DEVICE_URI|PRINTER_NAME]')
  121.             content.append(utils.USAGE_ARGS)
  122.             content.append(utils.USAGE_DEVICE)
  123.             content.append(utils.USAGE_PRINTER)
  124.         
  125.         if self.avail_modes is not None and self.num_valid_modes > 1:
  126.             summary.append('[MODE]')
  127.             content.append(utils.USAGE_SPACE)
  128.             content.append(utils.USAGE_MODE)
  129.             if self.num_installed_ui_toolkits > 0:
  130.                 if GUI_MODE in self.avail_modes and prop.gui_build:
  131.                     content.append(utils.USAGE_GUI_MODE)
  132.                 
  133.             
  134.             if INTERACTIVE_MODE in self.avail_modes:
  135.                 content.append(utils.USAGE_INTERACTIVE_MODE)
  136.             
  137.             if NON_INTERACTIVE_MODE in self.avail_modes:
  138.                 content.append(utils.USAGE_NON_INTERACTIVE_MODE)
  139.             
  140.         
  141.         summary.append('[OPTIONS]')
  142.         content.append(utils.USAGE_SPACE)
  143.         content.append(utils.USAGE_OPTIONS)
  144.         if self.avail_modes is not None and GUI_MODE in self.avail_modes and self.supported_ui_toolkits is not None and self.num_supported_ui_toolkits > 0 and prop.gui_build and self.num_installed_ui_toolkits > 0:
  145.             if UI_TOOLKIT_QT3 in self.supported_ui_toolkits and UI_TOOLKIT_QT3 in self.installed_ui_toolkits:
  146.                 content.append(utils.USAGE_USE_QT3)
  147.             
  148.             if UI_TOOLKIT_QT4 in self.supported_ui_toolkits and UI_TOOLKIT_QT4 in self.installed_ui_toolkits:
  149.                 content.append(utils.USAGE_USE_QT4)
  150.             
  151.         
  152.         content.append(utils.USAGE_LOGGING1)
  153.         content.append(utils.USAGE_LOGGING2)
  154.         if include_flags & USAGE_FLAG_SUPRESS_G_DEBUG_FLAG != USAGE_FLAG_SUPRESS_G_DEBUG_FLAG:
  155.             content.append(utils.USAGE_LOGGING3)
  156.         
  157.         content.append(utils.USAGE_HELP)
  158.         if extra_options is not None:
  159.             for e in extra_options:
  160.                 content.append(e)
  161.             
  162.         
  163.         if include_flags & USAGE_FLAG_FILE_ARGS:
  164.             summary.append('[FILES]')
  165.         
  166.         if extra_notes is not None or notes:
  167.             content.append(utils.USAGE_SPACE)
  168.             content.append(utils.USAGE_NOTES)
  169.             for n in notes:
  170.                 content.append(n)
  171.             
  172.             if extra_notes is not None:
  173.                 for n in extra_notes:
  174.                     content.append(n)
  175.                 
  176.             
  177.         
  178.         if see_also_list is not None:
  179.             content.append(utils.USAGE_SPACE)
  180.             content.append(utils.USAGE_SEEALSO)
  181.             for s in see_also_list:
  182.                 content.append((s, '', 'seealso', False))
  183.             
  184.         
  185.         content.insert(0, (' '.join(summary), '', 'summary', True))
  186.         for c in content:
  187.             self.usage_data.append(c)
  188.         
  189.  
  190.     
  191.     def parseStdOpts(self, extra_params = None, extra_long_params = None, handle_device_printer = True, supress_g_debug_flag = False):
  192.         params = 'l:h'
  193.         if not supress_g_debug_flag:
  194.             params = ''.join([
  195.                 params,
  196.                 'g'])
  197.         
  198.         long_params = [
  199.             'logging=',
  200.             'help',
  201.             'help-rest',
  202.             'help-man',
  203.             'help-desc',
  204.             'debug',
  205.             'dbg']
  206.         if handle_device_printer:
  207.             params = ''.join([
  208.                 params,
  209.                 'd:p:P:'])
  210.             long_params.extend([
  211.                 'device=',
  212.                 'device-uri=',
  213.                 'printer=',
  214.                 'printer-name'])
  215.         
  216.         if self.num_valid_modes > 1:
  217.             if GUI_MODE in self.avail_modes and prop.gui_build:
  218.                 params = ''.join([
  219.                     params,
  220.                     'u'])
  221.                 long_params.extend([
  222.                     'gui',
  223.                     'ui'])
  224.             
  225.             if INTERACTIVE_MODE in self.avail_modes:
  226.                 params = ''.join([
  227.                     params,
  228.                     'i'])
  229.                 long_params.extend([
  230.                     'interactive',
  231.                     'text'])
  232.             
  233.             if NON_INTERACTIVE_MODE in self.avail_modes:
  234.                 params = ''.join([
  235.                     params,
  236.                     'n'])
  237.                 long_params.extend([
  238.                     'noninteractive',
  239.                     'non-interactive',
  240.                     'batch'])
  241.             
  242.         
  243.         if self.supported_ui_toolkits is not None and self.num_supported_ui_toolkits > 1 and prop.gui_build and self.avail_modes is not None and GUI_MODE in self.avail_modes:
  244.             if UI_TOOLKIT_QT3 in self.supported_ui_toolkits and UI_TOOLKIT_QT3 in self.installed_ui_toolkits:
  245.                 long_params.extend([
  246.                     'qt3',
  247.                     'use-qt3'])
  248.             
  249.             if UI_TOOLKIT_QT4 in self.supported_ui_toolkits and UI_TOOLKIT_QT4 in self.installed_ui_toolkits:
  250.                 long_params.extend([
  251.                     'qt4',
  252.                     'use-qt4'])
  253.             
  254.         
  255.         if extra_params is not None:
  256.             params = ''.join([
  257.                 params,
  258.                 extra_params])
  259.         
  260.         if extra_long_params is not None:
  261.             long_params.extend(extra_long_params)
  262.         
  263.         opts = None
  264.         show_usage = None
  265.         device_uri = None
  266.         printer_name = None
  267.         error_msg = []
  268.         mode = self.default_mode
  269.         if prop.gui_build:
  270.             ui_toolkit = self.default_ui_toolkit
  271.         else:
  272.             ui_toolkit = 'none'
  273.         lang = None
  274.         
  275.         try:
  276.             (opts, self.args) = getopt.getopt(sys.argv[1:], params, long_params)
  277.         except getopt.GetoptError:
  278.             e = None
  279.             error_msg = [
  280.                 e.msg]
  281.  
  282.         for o, a in opts:
  283.             if o in ('-d', '--device', '--device-uri'):
  284.                 device_uri = a
  285.                 continue
  286.             None if o in ('-P', '-p', '--printer', '--printer-name') else log.set_level(log_level)
  287.             None if o in ('-g', '--debug', '--dbg') else prop.gui_build
  288.             if o in ('-i', '--interactive', '--text'):
  289.                 if self.avail_modes is not None and INTERACTIVE_MODE in self.avail_modes:
  290.                     mode = INTERACTIVE_MODE
  291.                     ui_toolkit = 'none'
  292.                 
  293.             INTERACTIVE_MODE in self.avail_modes
  294.             if o in ('-n', '--non-interactive', '--batch'):
  295.                 if self.avail_modes is not None and NON_INTERACTIVE_MODE in self.avail_modes:
  296.                     mode = NON_INTERACTIVE_MODE
  297.                     ui_toolkit = 'none'
  298.                 
  299.             NON_INTERACTIVE_MODE in self.avail_modes
  300.             if o in ('-h', '--help'):
  301.                 show_usage = 'text'
  302.                 continue
  303.             if o == '--help-rest':
  304.                 show_usage = 'rest'
  305.                 continue
  306.             if o == '--help-man':
  307.                 show_usage = 'man'
  308.                 continue
  309.             None if o == '--help-desc' else GUI_MODE in self.avail_modes
  310.             if o in ('--qt4', '--use-qt4'):
  311.                 if self.avail_modes is not None and GUI_MODE in self.avail_modes:
  312.                     if self.supported_ui_toolkits is not None and UI_TOOLKIT_QT4 in self.supported_ui_toolkits and prop.gui_build and UI_TOOLKIT_QT4 in self.installed_ui_toolkits:
  313.                         mode = GUI_MODE
  314.                         ui_toolkit = 'qt4'
  315.                     else:
  316.                         error_msg.append('%s does not support Qt4. Unable to enter GUI mode.' % self.mod)
  317.                 
  318.             GUI_MODE in self.avail_modes
  319.         
  320.         if error_msg:
  321.             show_usage = 'text'
  322.         
  323.         self.usage(show_usage, error_msg)
  324.         if show_usage is not None:
  325.             sys.exit(0)
  326.         
  327.         self.mode = mode
  328.         return (opts, device_uri, printer_name, mode, ui_toolkit, lang)
  329.  
  330.     
  331.     def showLanguages(self):
  332.         f = tui.Formatter()
  333.         f.header = ('Language Code', 'Alternate Name(s)')
  334.         for loc, ll in supported_locales.items():
  335.             f.add((ll[0], ', '.join(ll[1:])))
  336.         
  337.         f.output()
  338.  
  339.     
  340.     def usage(self, show_usage = 'text', error_msg = None):
  341.         if show_usage is None:
  342.             if not self.quiet:
  343.                 self.showTitle()
  344.             
  345.             return None
  346.         if show_usage == 'text':
  347.             self.showTitle()
  348.             log.info()
  349.         
  350.         if show_usage == 'desc':
  351.             print self.doc
  352.         else:
  353.             utils.format_text(self.usage_data, show_usage, self.title, self.mod, self.version)
  354.             if error_msg:
  355.                 for e in error_msg:
  356.                     log.error(e)
  357.                 
  358.                 sys.exit(1)
  359.             
  360.             sys.exit(0)
  361.             if show_usage == 'text':
  362.                 sys.exit(0)
  363.             
  364.  
  365.     
  366.     def showTitle(self, show_ver = True):
  367.         if not self.quiet:
  368.             log.info('')
  369.             if show_ver:
  370.                 log.info(log.bold('HP Linux Imaging and Printing System (ver. %s)' % prop.version))
  371.             else:
  372.                 log.info(log.bold('HP Linux Imaging and Printing System'))
  373.             log.info(log.bold('%s ver. %s' % (self.title, self.version)))
  374.             log.info('')
  375.             log.info('Copyright (c) 2001-9 Hewlett-Packard Development Company, LP')
  376.             log.info('This software comes with ABSOLUTELY NO WARRANTY.')
  377.             log.info('This is free software, and you are welcome to distribute it')
  378.             log.info('under certain conditions. See COPYING file for more details.')
  379.             log.info('')
  380.         
  381.  
  382.     
  383.     def getDeviceUri(self, device_uri = None, printer_name = None, back_end_filter = device.DEFAULT_BE_FILTER, filter = device.DEFAULT_FILTER, devices = None, restrict_to_installed_devices = True):
  384.         """ Validate passed in parameters, and, if in text mode, have user select desired device to use.
  385.             Used for tools that are device-centric and accept -d (and maybe also -p).
  386.             Use the filter(s) to restrict what constitute valid devices.
  387.  
  388.             Return the matching device URI based on:
  389.             1. Passed in device_uri if it is valid (filter passes)
  390.             2. Corresponding device_uri from the printer_name if it is valid (filter passes) ('*' means default printer)
  391.             3. User input from menu (based on bus and filter)
  392.  
  393.             device_uri and printer_name can both be specified if they correspond to the same device.
  394.  
  395.             Returns:
  396.                 device_uri|None
  397.                 (returns None if passed in device_uri is invalid or printer_name doesn't correspond to device_uri)
  398.         """
  399.         log.debug('getDeviceUri(%s, %s, %s, %s, , %s)' % (device_uri, printer_name, back_end_filter, filter, restrict_to_installed_devices))
  400.         log.debug('Mode=%s' % self.mode)
  401.         scan_uri_flag = False
  402.         if 'hpaio' in back_end_filter:
  403.             scan_uri_flag = True
  404.         
  405.         device_uri_ok = False
  406.         printer_name_ok = False
  407.         device_uri_ret = None
  408.         if devices is None:
  409.             devices = device.getSupportedCUPSDevices(back_end_filter, filter)
  410.             log.debug(devices)
  411.         
  412.         if device_uri is not None:
  413.             if device_uri in devices:
  414.                 device_uri_ok = True
  415.             elif restrict_to_installed_devices:
  416.                 log.error('Invalid device URI: %s' % device_uri)
  417.                 device_uri = None
  418.             else:
  419.                 device_uri_ok = True
  420.         
  421.         if printer_name is not None:
  422.             printers = device.getSupportedCUPSPrinterNames(back_end_filter, filter)
  423.             if printer_name in printers:
  424.                 printer_name_ok = True
  425.                 printer_name_device_uri = device.getDeviceURIByPrinterName(printer_name, scan_uri_flag)
  426.             else:
  427.                 log.error('Invalid printer name: %s' % printer_name)
  428.                 printer_name = None
  429.         
  430.         if device_uri is not None and printer_name is None and device_uri_ok:
  431.             device_uri_ret = device_uri
  432.         elif device_uri is not None and printer_name is not None:
  433.             if device_uri_ok and printer_name_ok:
  434.                 if device_uri == printer_name_device_uri:
  435.                     device_uri_ret = device_uri
  436.                 else:
  437.                     log.error('Printer name %s and device URI %s refer to different devices.' % (printer_name, device_uri))
  438.                     (printer_name, printer_name) = (None, None)
  439.             
  440.         elif device_uri is None and printer_name is not None and printer_name_ok:
  441.             device_uri_ret = device.getDeviceURIByPrinterName(printer_name, scan_uri_flag)
  442.         elif len(devices) == 1:
  443.             device_uri_ret = devices.keys()[0]
  444.             log.info('Using device: %s\n' % device_uri_ret)
  445.         
  446.         if device_uri_ret is None and self.mode in (INTERACTIVE_MODE, NON_INTERACTIVE_MODE) and len(devices):
  447.             device_uri_ret = tui.device_table(devices, scan_uri_flag)
  448.         
  449.         if device_uri_ret is not None:
  450.             user_conf.set('last_used', 'device_uri', device_uri_ret)
  451.         elif self.mode in (INTERACTIVE_MODE, NON_INTERACTIVE_MODE):
  452.             log.error('No device selected/specified or that supports this functionality.')
  453.             sys.exit(1)
  454.         else:
  455.             log.debug('No device selected/specified')
  456.         return device_uri_ret
  457.  
  458.     
  459.     def getPrinterName(self, printer_name, device_uri, back_end_filter = device.DEFAULT_BE_FILTER, filter = device.DEFAULT_FILTER):
  460.         """ Validate passed in parameters, and, if in text mode, have user select desired printer to use.
  461.             Used for tools that are printer queue-centric and accept -p (and maybe also -d).
  462.             Use the filter(s) to restrict what constitute valid printers.
  463.  
  464.             Return the matching printer_name based on:
  465.             1. Passed in printer_name if it is valid (filter passes) ('*' means default printer)
  466.             2. From single printer_name of corresponding passed in device_uri (filter passes)
  467.             3. User input from menu (CUPS printer list, filtered) [or if > 1 queue for device_uri]
  468.  
  469.             device_uri and printer_name can both be specified if they correspond to the same device.
  470.  
  471.             Returns:
  472.                 (printer_name|None, device_uri|None) (tuple)
  473.                 (returns None if passed in printer_name is invalid or device_uri doesn't correspond to printer_name)
  474.         """
  475.         log.debug('getPrinterName(%s, %s, %s, %s)' % (device_uri, printer_name, back_end_filter, filter))
  476.         log.debug('Mode=%s' % self.mode)
  477.         device_uri_ok = False
  478.         printer_name_ok = False
  479.         printer_name_ret = None
  480.         device_uri_ret = None
  481.         printers = device.getSupportedCUPSPrinterNames(back_end_filter, filter)
  482.         log.debug(printers)
  483.         if device_uri is not None:
  484.             devices = device.getSupportedCUPSDevices(back_end_filter, filter)
  485.             if device_uri in devices:
  486.                 device_uri_ok = True
  487.                 device_uri_ret = device_uri
  488.             else:
  489.                 log.error('Invalid device URI: %s' % device_uri)
  490.                 device_uri = None
  491.         
  492.         if printer_name is not None:
  493.             if printer_name == '*':
  494.                 cups = cups
  495.                 import prnt
  496.                 default_printer = cups.getDefaultPrinter()
  497.                 if default_printer is not None:
  498.                     printer_name_ret = default_printer
  499.                 else:
  500.                     log.error('CUPS default printer not set')
  501.                     printer_name = None
  502.             elif printer_name in printers:
  503.                 printer_name_ok = True
  504.                 device_uri_ret = device.getDeviceURIByPrinterName(printer_name)
  505.             else:
  506.                 log.error('Invalid printer name')
  507.                 printer_name = None
  508.         
  509.         if device_uri is not None and printer_name is None and device_uri_ok:
  510.             if len(devices[device_uri]) == 1:
  511.                 printer_name_ret = devices[device_uri][0]
  512.             
  513.         elif device_uri is not None and printer_name is not None:
  514.             if device_uri_ok and printer_name_ok:
  515.                 if device_uri == device_uri_ret:
  516.                     printer_name_ret = printer_name
  517.                 else:
  518.                     log.error('Printer name and device URI refer to different devices.')
  519.             
  520.         elif device_uri is None and printer_name is not None and printer_name_ok:
  521.             printer_name_ret = printer_name
  522.         elif len(printers) == 1:
  523.             printer_name_ret = printers[0]
  524.             log.info('Using printer: %s\n' % printer_name_ret)
  525.         
  526.         if printer_name_ret is None and self.mode in (INTERACTIVE_MODE, NON_INTERACTIVE_MODE) and len(printers):
  527.             printer_name_ret = tui.printer_table(printers)
  528.         
  529.         if printer_name_ret is not None and device_uri_ret is None:
  530.             device_uri_ret = device.getDeviceURIByPrinterName(printer_name_ret)
  531.         
  532.         if device_uri_ret is not None:
  533.             user_conf.set('last_used', 'device_uri', device_uri_ret)
  534.         
  535.         if printer_name_ret is not None:
  536.             user_conf.set('last_used', 'printer_name', printer_name_ret)
  537.         elif self.mode in (INTERACTIVE_MODE, NON_INTERACTIVE_MODE):
  538.             log.error('No printer selected/specified or that supports this functionality.')
  539.             sys.exit(1)
  540.         else:
  541.             log.debug('No printer selected/specified')
  542.         return (printer_name_ret, device_uri_ret)
  543.  
  544.     
  545.     def lockInstance(self, suffix = ''):
  546.         if suffix:
  547.             (ok, self.lock_file) = utils.lock_app('-'.join([
  548.                 self.mod,
  549.                 suffix]))
  550.         else:
  551.             (ok, self.lock_file) = utils.lock_app(self.mod)
  552.         if not ok:
  553.             sys.exit(1)
  554.         
  555.  
  556.     
  557.     def unlockInstance(self):
  558.         if self.lock_file is not None:
  559.             utils.unlock(self.lock_file)
  560.         
  561.  
  562.  
  563.